package com.horay.statemachiedemo.multi.persist.config;

import com.horay.statemachiedemo.multi.enums.OrderState;
import com.horay.statemachiedemo.multi.event.OrderEvent;
import com.horay.statemachiedemo.multi.persist.OrderMemoryStateMachinePersist;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.statemachine.persist.DefaultStateMachinePersister;
import org.springframework.statemachine.persist.StateMachinePersister;

/**
 * Class description
 *
 * @author heyingcheng
 * @date 2020/10/23
 */
@Configuration("orderMemoryPersistConfig")
public class OrderMemoryPersistConfig {

    private final OrderMemoryStateMachinePersist orderMemoryStateMachinePersist;

    public OrderMemoryPersistConfig(OrderMemoryStateMachinePersist orderMemoryStateMachinePersist) {
        this.orderMemoryStateMachinePersist = orderMemoryStateMachinePersist;
    }

    @Bean
    public StateMachinePersister<OrderState, OrderEvent, String> orderMemoryStateMachinePersister() {
        return new DefaultStateMachinePersister<>(orderMemoryStateMachinePersist);
    }

}
